package de.gameduell.framework.gui.animation {

	/**
	 * @author mgeb
	 */
	public class BezierTween extends GDTween implements Tweenable{
		
		public var point1:Number;
		public var point2:Number;
		
		/**  
		 * @param obj      	 = the object that will be tweened
		 * @param prop    	 = the property that will be tweened
		 * @param begin   	 = the startingpoint of the curve
		 * @param finish  	 = the endpoint of the curve
		 * @param duration	 = the duration of the tweening
		 * @param aPoint1 	 = the first calculationpoint of the beziercurve 
		 * @param aPoint2 	 = the second calculationpoint of the beziercurve 
		 * @param useSeconds = use seconds or milliseconds
		**/
		public function BezierTween(obj:Object, prop:String, begin:Number, finish:Number, duration:Number, aPoint1:Number, aPoint2:Number, useSeconds:Boolean = false) {
			super(obj, prop, tweenCubicBez, begin, finish, duration, useSeconds);
			point1 = aPoint1;
			point2 = aPoint2;
		}
	

		/**  
		 * @param t = the current value of the time of the duration between "0" and the "duration" of the tweening 
		 * @param b = the startingvalue of the animationproperty
		 * @param c = the change of the animationproperty in total
		 * @param d = duration  of the movement
		**/
		public function tweenCubicBez (t:Number, b:Number, c:Number, d:Number):Number {
			return ((t/=d)*t*c + 3*(1-t)*(t*(point2-b) + (1-t)*(point1-b)))*t + b;
		}	
	}
}
